import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/models/xindong_income_class.dart';
import 'package:xindong/routes/user/income/xindong_income_vm.dart';

class XinDongIncomeListViewCell extends StatelessWidget {
  final bool isZhangDan;
  final XinDongIncomeClass model;

  const XinDongIncomeListViewCell({super.key, required this.model, this.isZhangDan = false});

  @override
  Widget build(BuildContext context) {
    // 账单是types反过来的
    bool isIn = isZhangDan ? model.types == IncomeType.zhichu : model.types == IncomeType.shouru;
    String util = isZhangDan ? "金币" : "元";
    String moneyText = "${isIn ? "+" : "-"} ${model.money}$util";
    Color moneyColor = isIn ? DZColors.moneyColor : Colors.red;
    return Container(
      color: DZColors.cellColor,
      padding: const EdgeInsets.only(left: kPaddingValue, right: kPaddingValue, top: 10, bottom: 10),
      child: Row(
        children: [
          Expanded(
            child: Text(
              model.content,
              // maxLines: 0,
              style: const TextStyle(fontSize: 15, color: DZColors.titleColor),
            ),
          ),
          const SizedBox(width: 10),
          Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Text(
                moneyText,
                maxLines: 1,
                textAlign: TextAlign.right,
                style: TextStyle(fontSize: 16, color: moneyColor),
              ),
              const SizedBox(height: 5),
              Text(
                model.time,
                maxLines: 1,
                textAlign: TextAlign.right,
                style: const TextStyle(fontSize: 13, color: DZColors.placeholderColor),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
